#!/bin/bash
if [ $# -ne 3 ]
then
	echo arg length $#
	echo "Requires filtered_associations_file.tsv, phenoProt_transposed.csv, dataset_label as arguments"
	exit
fi
NOW=$(date +"%T")
associations_file=$1
input_transposed_file=$2
dataset_label=$3
features_table=$dataset_label"_features"

/Library/Frameworks/Python.framework/Versions/2.6/bin/python createSchemaFromTemplate.py $dataset_label
schema_file="./create_schema_"$dataset_label".sql"

echo begin processing, clean and rebuild schema $(date) for label $dataset_label
mysql -ududley_omics -pdud1ey < $schema_file

echo created schema, begin parsing and loading features $(date) for $associations_file $input_transposed_file
/Library/Frameworks/Python.framework/Versions/2.6/bin/python ./parse_features_kruglyak.py $associations_file $dataset_label
echo parsed and loaded features $(date)

/Library/Frameworks/Python.framework/Versions/2.6/bin/python ./parse_associations_kruglyak.py $associations_file $dataset_label

echo parsed and loaded associations $(date)

/Library/Frameworks/Python.framework/Versions/2.6/bin/python ./parse_samples_values.py $input_transposed_file $dataset_label
echo parsed and loaded strains and values $(date)

mysql -ududley_omics -pdud1ey < ./populate_mv_kruglyak_rface.sql
echo populated materialize view, program done $(date)


